package com.ruoyi.teacher.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.teacher.domain.vo.QueryParamsVO;
import com.ruoyi.teacher.domain.vo.QueryVO;
import com.ruoyi.teacher.service.ITeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.annotation.MultipartConfig;
import java.util.List;

/**
 * 自定义查询信息
 *
 * @author xiangzy
 */
@Api(tags = "自定义查询管理")
@RestController
@RequestMapping("/customQuery")
public class CustomQueryController extends BaseController {

    @Autowired
    private ITeacherService teacherService;

    /**
     * 获取自定义查询结果列表
     */
    @ApiOperation(value = "自定义查询结果列表")
    @PostMapping("/customQueryList")
    public TableDataInfo customQueryList(@RequestBody QueryParamsVO query) {

        startPage();
        List<QueryVO> queryResult = teacherService.selectQueryResult(query);
        logger.info("查询出的教师列表为{}",queryResult);
        return getDataTable(queryResult);
    }
    /**
     * 导出自定义查询结果列表
     */
    @Log(title = "自定义查询管理", businessType = BusinessType.EXPORT)
    @ApiOperation(value = "自定义查询结果列表导出")
    @GetMapping("/{A00s}")
    public AjaxResult export(@PathVariable Long[] A00s)
    {
        List<QueryVO> list = teacherService.selectListByA00s(A00s);
        ExcelUtil<QueryVO> util = new ExcelUtil<QueryVO>(QueryVO.class);
        return util.exportExcel(list, "自定义查询结果列表");
    }

}
